﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Controls;

namespace Asteroids.Game.ViewModel
{
    class PlayerLivesViewModel : INotifyPropertyChanged
    {
        public int Lives { get; set; }
        public String LivesText
        {
            get { return String.Format("Lives: {0}", Lives); }
        }

        public PlayerLivesViewModel()
        {
            Game.Instance.Player.PlayerShipCountChanged += SetLivesCount;
            Game.Instance.Player.PlayerShipCountChanged(this, EventArgs.Empty);
        }

        private void SetLivesCount(object s, EventArgs e)
        {
            Lives = Game.Instance.Player.NumShips;
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(""));
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
